package com.ruoyi.core.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.core.service.ServerConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Validated
@Api(tags = "服务器管理")
@RequestMapping("/server-config")
public class ServerConfigController {

    @Autowired
    private ServerConfigService serverConfigService;

    @GetMapping(value = "/getServerList")
    @ApiOperation("获取服务器列表")
    public TableDataInfo getServerList(){
        return serverConfigService.getServerList();
    }

    @GetMapping(value = "enable")
    @ApiOperation("启用服务器")
    public AjaxResult enable(@RequestParam Long id){
        serverConfigService.enableServer(id);
        return AjaxResult.success();
    }
}
